Skip to content

fix parsing issue with --gtest_list_tests output on newer versions of google_test#24

Closed
willsheffler wants to merge 1 commit intopytest-dev:masterfrom
willsheffler:master
Closed

fix parsing issue with --gtest_list_tests output on newer versions of google_test#24
willsheffler wants to merge 1 commit intopytest-dev:masterfrom
willsheffler:master

Conversation

@willsheffler
Copy link
Copy Markdown

First public github pull request I've done, apologies if I'm doing something dumb. (Like, if a PR isn't the right way to request this change...)

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.4%) to 99.209% when pulling cfa063a on willsheffler:master into 7e627f8 on pytest-dev:master.

@nicoddemus
Copy link
Copy Markdown
Member

Hey @willsheffler, thanks for the PR!

First public github pull request I've done, apologies if I'm doing something dumb. (Like, if a PR isn't the right way to request this change...)

Not at all, PRs are an excellent way to request changes like this!

fix parsing issue with --gtest_list_tests output on newer versions of google_test

I don't use Google Test on daily basis, so if you could could clarify some questions it would be great:

  • Which change to --gtest_list_tests output broke pytest-cpp? Looking at the CHANGELOG for 1.7, I see two potential changes:

    • New feature (potentially breaking): --gtest_list_tests now prints
      the type parameters and value parameters for each test.
    • Potentially breaking change: RUN_ALL_TESTS() is now implemented as a
      function instead of a macro in order to work better with Clang.

    It would be nice to pinpoint the exact change so we can mention it in the CHANGELOG.

  • Could you supply some sample of the new output? I'm a little short on time right now to install a new google test version.

Again, thanks for taking the time to submit this! 😁

@willsheffler
Copy link
Copy Markdown
Author

Here's some sample output from google_test 1.8.0 (https://github.com/google/googletest/releases)
the header output seems to be new (?). Or at least, pytest_cpp was getting tripped up on the "int main....", and "--gtest_list_tests" lines.

int main(int argc, char **argv) FROM ../../src/test/main_test.cc
init_gtest_tests(
/Users/sheffler/ClionProjects/rif/build_setup_py/temp.macosx-10.6-x86_64-2.7/src/test/all_test_libscheme
--gtest_list_tests
) FROM ../../src/test/./gtest_util.hh
RUN_ALL_TESTS FROM ../../src/test/./gtest_util.hh
BackboneActor.
test_from_N_CA_C
test_get_N_CA_C
...

perhaps it would be better to check the first character in the stripped line isalpha or underscore (those are I think the allowed start to c++ identifiers)

not sure how to fix the coverage without adding a test case with newer gtest.

thanks!

@nicoddemus
Copy link
Copy Markdown
Member

not sure how to fix the coverage without adding a test case with newer gtest.

Thanks! I will take a look on how to make a separate build matrix for different GTest versions.

@nicoddemus
Copy link
Copy Markdown
Member

Hey @willsheffler sorry for the lack of response on this; it got lost on my list of TODO items. I will get back to this this week.

@nicoddemus
Copy link
Copy Markdown
Member

Hi @willsheffler,

I managed to install googletest and take a look myself. I don't see the same output as you:

[==========] Running 3 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 3 tests from FooTest
[ RUN      ] FooTest.test_success
[       OK ] FooTest.test_success (0 ms)
[ RUN      ] FooTest.test_failure
gtest.cpp:17: Failure
      Expected: 2 * 3
      Which is: 6
To be equal to: 5
gtest.cpp:18: Failure
      Expected: 2 * 6
      Which is: 12
To be equal to: 15
[  FAILED  ] FooTest.test_failure (0 ms)
[ RUN      ] FooTest.test_error
unknown file: Failure
C++ exception with description "unexpected exception" thrown in the test body.
[  FAILED  ] FooTest.test_error (0 ms)
[----------] 3 tests from FooTest (0 ms total)

[----------] Global test environment tear-down
[==========] 3 tests from 1 test case ran. (1 ms total)
[  PASSED  ] 1 test.
[  FAILED  ] 2 tests, listed below:
[  FAILED  ] FooTest.test_failure
[  FAILED  ] FooTest.test_error

 2 FAILED TESTS
  YOU HAVE 1 DISABLED TEST

And that works fine with pytest-cpp:

================================================ test session starts ================================================

platform linux2 -- Python 2.7.6, pytest-3.0.4, py-1.4.31, pluggy-0.4.0
rootdir: /home/vagrant/pytest-cpp, inifile:
plugins: cpp-0.4.1, mock-1.4.0
collected 4 items

tests/gtest .FFs

===================================================== FAILURES ======================================================

_______________________________________________ FooTest.test_failure ________________________________________________

      Expected: 2 * 3
      Which is: 6
To be equal to: 5
gtest.cpp:17: C++ failure
---
      Expected: 2 * 6
      Which is: 12
To be equal to: 15
gtest.cpp:18: C++ failure
________________________________________________ FooTest.test_error _________________________________________________

unknown file
C++ exception with description "unexpected exception" thrown in the test body.
unknown file:0: C++ failure
=================================== 2 failed, 1 passed, 1 skipped in 0.02 seconds ===================================

I have compiled googletest with standard options (just cmake && cmake install). Perhaps you have it compiled differently so it is giving more output, perhaps debugging output?

I'm about to open a PR testing pytest-cpp with googletest-1.8.0, will post it here.

@willsheffler
Copy link
Copy Markdown
Author

Thanks for looking into it. Can't remember exactly built googletest, but
I'll give it another shot.
Will

On Nov 21, 2016 10:45 AM, "Bruno Oliveira" notifications@github.com wrote:

Hi @willsheffler https://github.com/willsheffler,

I managed to install googletest and take a look myself. I don't see the
same output as you:

[==========] Running 3 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 3 tests from FooTest
[ RUN ] FooTest.test_success
[ OK ] FooTest.test_success (0 ms)
[ RUN ] FooTest.test_failure
gtest.cpp:17: Failure
Expected: 2 * 3
Which is: 6
To be equal to: 5
gtest.cpp:18: Failure
Expected: 2 * 6
Which is: 12
To be equal to: 15
[ FAILED ] FooTest.test_failure (0 ms)
[ RUN ] FooTest.test_error
unknown file: Failure
C++ exception with description "unexpected exception" thrown in the test body.
[ FAILED ] FooTest.test_error (0 ms)
[----------] 3 tests from FooTest (0 ms total)

[----------] Global test environment tear-down
[==========] 3 tests from 1 test case ran. (1 ms total)
[ PASSED ] 1 test.
[ FAILED ] 2 tests, listed below:
[ FAILED ] FooTest.test_failure
[ FAILED ] FooTest.test_error

2 FAILED TESTS
YOU HAVE 1 DISABLED TEST

And that works fine with pytest-cpp:

================================================ test session starts ================================================

platform linux2 -- Python 2.7.6, pytest-3.0.4, py-1.4.31, pluggy-0.4.0
rootdir: /home/vagrant/pytest-cpp, inifile:
plugins: cpp-0.4.1, mock-1.4.0
collected 4 items

tests/gtest .FFs

===================================================== FAILURES ======================================================

_______________________________________________ FooTest.test_failure ________________________________________________

  Expected: 2 * 3
  Which is: 6

To be equal to: 5

gtest.cpp:17: C++ failure

  Expected: 2 * 6
  Which is: 12

To be equal to: 15
gtest.cpp:18: C++ failure
________________________________________________ FooTest.test_error _________________________________________________

unknown file
C++ exception with description "unexpected exception" thrown in the test body.
unknown file:0: C++ failure
=================================== 2 failed, 1 passed, 1 skipped in 0.02 seconds ===================================

I have compiled googletest with standard options (just cmake && cmake
install). Perhaps you have it compiled differently so it is giving more
output, perhaps debugging output?

I'm about to open a PR testing pytest-cpp with googletest-1.8.0, will post
it here.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#24 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAbx5VD_Orm_AU-DuXX_4sWHrt40_9roks5rAeaxgaJpZM4KCHLL
.

@nicoddemus
Copy link
Copy Markdown
Member

Created #28, now testing with 1.8.0 in Travis. 😁

Thanks again for the PR @willsheffler. I will close this for now, feel free to reopen if you have new information. 👍

@nicoddemus nicoddemus closed this Nov 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants